home *** CD-ROM | disk | FTP | other *** search
/ Aminet 16 / Aminet 16 (1996)(GTI - Schatztruhe)[!][Dec 1996].iso / Aminet / dev / src / wangisrc.lha / wangi / z / oldwp / Menu / WangiPad.PAS < prev    next >
Pascal/Delphi Source File  |  1996-01-17  |  6KB  |  232 lines

  1. Program WangiPad;
  2. {SF-,I-,R-,S-,V-}
  3. {$M 4,1,1,15}
  4.  
  5. Uses
  6.     Exec, Intuition, GadTools, Utility, Graphics, Diskfont, 
  7.     Icon, WBStart, KeyFile, Amiga, AmigaDos, DOS, Reqtools, 
  8.     WorkBench, Commodities, Rexx, Timer, PathList;
  9.  
  10. Type    
  11.     pEnDisWin = ^tEnDisWin;
  12.     tEnDisWin = Record
  13.         edw_req : pRequester;
  14.         edw_oldwidth,
  15.         edw_oldheight : LONG;
  16.     End;
  17.     
  18.     pIPCMsg = ^tIPCMsg;
  19.     tIPCMsg = record
  20.         ipc_Msg    : tMessage; { system message structure                   }
  21.         ipc_Type,              { type of message                            }
  22.         ipc_Left,              { dimension of window if type = IPC_SENDSIZE }
  23.         ipc_Top,
  24.         ipc_Width,
  25.         ipc_Height : LONG
  26.     End;
  27.     
  28.     tProgVars = Record
  29.         arg_From,
  30.         arg_Hotkey,
  31.         arg_PrefEd : String[180];
  32.         arg_Pri,
  33.         arg_LevelT : LONG;
  34.     End;
  35.     
  36. Const
  37.     { constants fo ipc_Type }
  38.     IPC_SENDSIZES    = 1;
  39.     IPC_NEWPREFS     = 2;
  40.     IPC_REQUESTSIZES = 3;
  41.     grk   : pRemember = NIL;
  42.     prk   : pRemember = NIL;
  43.     opened : Boolean = True;
  44.     secs  : LONG = 0;
  45.     mics  : LONG = 0;
  46.     G_NI  = 0;
  47.     G_LV  = 1;
  48.     G_CC  = 2;
  49.     
  50.     TBS     = 0;
  51.     S_Gad_H = 1;
  52.     
  53.     M_PREF  = 4;
  54.     M_ABOUT = 5;
  55.     M_HIDE  = 2;
  56.     M_QUIT  = 3;
  57.     
  58.     ERROR_LOSTPREFS = 'Can''t find preference program';
  59.     ERROR_WB        = 'launching Workbench program';
  60.     ERROR_SHELL     = 'launching Shell program';
  61.     ERROR_NOTWB2    = 'Drag ''n'' Drop requires Workbench 3, sorry';
  62.  
  63.     
  64.     
  65. Var
  66.     Reg         : tKey;
  67.     CurrentList : pList;
  68.     S           : Array[0..1] of LONG;
  69.     G           : Array[G_NI..G_CC] of pGadget;
  70.     vi          : Pointer;
  71.     My_Font     : tTextAttr;
  72.     menustrip   : pMenu;
  73.     OK          : Boolean;
  74.     oldsecs, 
  75.     oldmics,
  76.     oldlvord,
  77.     LVRows,
  78.     currenttop  : LONG;
  79.     aw          : pAppWindow;
  80.     AppPort, CxPort,
  81.     WangiPort, NotifyPort,
  82.     WBMPort,
  83.     timerport   : pMsgPort;
  84.     broker, filter,
  85.     sender,
  86.     translate   : pCxObj;
  87.     nr          : pNotifyRequest;
  88.     V           : tProgVars;
  89.     HidenPos    : Array[1..4] of LONG;
  90.     tio         : pTimeRequest;
  91.     gp          : pPathList;
  92.     wbmlist : tMinList;
  93.     
  94. function CStrConstPtrAR(rk : ppRemember; s : String) : STRPTR;
  95. VAR
  96.     p : STRPTR;
  97. begin
  98.   s := s + #0;                                   { Make "C" string               }
  99.   p := AllocRemember(rk, length(s), MEMF_CLEAR); { Get some mem for it           }
  100.   move(s[1], p^, length(s));                     { Move s into newly alloc'd mem }
  101.   CStrConstPtrAR := p;                           { Return the pointer            }
  102. end;
  103.  
  104. Procedure TellError(txt : String);
  105.  
  106. Var
  107.     gad, tit : String;
  108.     ret      : Longint;
  109.     ez       : pEasyStruct;
  110.     
  111. Begin
  112.     gad := 'Ok'#0;
  113.     tit := 'WangiPad Error'#0;
  114.     txt := 'Error ' + txt;
  115.     If CmdLinePtr.Len >= 1 then begin
  116.         txt := txt + #10#0;
  117.         ret := FPuts(Output_,@txt[1]);
  118.     End else begin
  119.         txt := txt + #0;
  120.         If IntuitionBase <> NIL then begin
  121.             ez := AllocVec(Sizeof(tEasyStruct),MEMF_CLEAR);
  122.             if ez <> NIL then begin
  123.                 with ez^ do begin
  124.                     es_StructSize := Sizeof(tEasyStruct);
  125.                     es_Title := @tit[1];
  126.                     es_TextFormat := @txt[1];
  127.                     es_GadgetFormat := @gad[1];
  128.                 End;
  129.                 ret := EasyRequestArgs(NIL, ez, NIL, NIL);
  130.                 FreeVec(ez);
  131.             End;
  132.         End;
  133.     End;
  134. End;
  135.         
  136.  
  137. Function PutArgs(cmd : String; am : pAppMessage) : String; Forward;
  138.  
  139. {$I Version.H      }
  140. {$I Config.PAS     }
  141. {$I ToolType.PAS   }
  142. {$I Window.PAS     }
  143. {$I ARexx.PAS      }
  144. {$I ProcessMsg.PAS }
  145.  
  146.  
  147. Procedure Main;
  148. Var
  149.     Win   : pWindow;
  150.     owp   : Pointer;
  151.  
  152. Begin
  153.     if pLibrary(SysBase)^.lib_Version < 37 then begin
  154.         Halt;
  155.     End;
  156.     IntuitionBase := NIL;
  157.     IntuitionBase := pIntuitionBase(OpenLibrary('intuition.library',36));
  158.     If IntuitionBase <> NIL then begin
  159.         GadToolsBase := OpenLibrary('gadtools.library', 36);
  160.         If GadToolsBase <> NIL then begin
  161.             GfxBase := pGfxBase(OpenLibrary('graphics.library',0));
  162.             If GfxBase <> NIL then begin
  163.                 WorkbenchBase := OpenLibrary('workbench.library',36);
  164.                 If WorkbenchBase <> NIL then begin
  165.                     CxBase := OpenLibrary('commodities.library', 37);
  166.                     If CxBase <> NIL then begin
  167.                         DiskFontBase := OpenLibrary('diskfont.library',0);
  168.                         If DiskfontBase <> NIL then begin
  169.                             IconBase := OpenLibrary('icon.library',0);
  170.                             If IconBase <> NIL then begin
  171.                                 ReqtoolsBase := pReqtoolsBase(OpenLibrary('reqtools.library',38));
  172.                                 RexxSysBase := pRxsLib(OpenLibrary('rexxsyslib.library',0));
  173.     
  174.                                 GetToolTypes(v);
  175.         
  176.                                 if ReadConfigFile(V.arg_From,LM_LOAD,prk) then begin
  177.                                     ReadKeyFile(reg, 'S:WangiPad.key');
  178.                                     Win := OpenTheWindow;
  179.                                     if Win <> NIL then begin
  180.                                         owp := pProcess(ThisTask)^.pr_WindowPtr;
  181.                                         pProcess(ThisTask)^.pr_WindowPtr := Win;
  182.                                         If InitCx then begin
  183.                                             If AddAppWin(win) then begin
  184.                                                 If InitIPC then begin
  185.                                                     If InitNotify then begin
  186.                                                         If InitTimer then begin
  187.                                                             If InitWBMenus then begin
  188.                                                                 InitPathList(gp);
  189.                                                                 InitMenus(win);
  190.                                                                 ProcessWindowEvents(win);
  191.                                                                 FreeMenus(win);
  192.                                                                 FreePathList(gp);
  193.                                                                 FreeWBMenus;
  194.                                                             End;
  195.                                                             CloseTimer;
  196.                                                         End else TellError('13');
  197.                                                         RemoveNotify;
  198.                                                     End else TellError('12'); 
  199.                                                     RemoveIPC;
  200.                                                 End else TellError('11');
  201.                                                 RemoveAppWin;
  202.                                             End else TellError('10');
  203.                                             RemoveCx;
  204.                                         End else TellError('9');
  205.                                         pProcess(ThisTask)^.pr_WindowPtr := owp;
  206.                                         CloseTheWindow(win);
  207.                                         CloseFont(CD.cd_TFont);
  208.                                     End else TellError('8');
  209.                                 End else TellError('7 - Unable to load preference file.');
  210.                                 FreeRemember(@grk, True);
  211.                                 FreeRemember(@prk, True);
  212.                                 
  213.                                 { Close all system modules }
  214.                                 CloseLibrary(pLibrary(RexxSysBase));
  215.                                 CloseLibrary(pLibrary(ReqtoolsBase));
  216.                                 CloseLibrary(pLibrary(IconBase));
  217.                             End else TellError('6');
  218.                             CloseLibrary(pLibrary(DiskFontBase));
  219.                         End else TellError('5');
  220.                         CloseLibrary(pLibrary(CxBase));
  221.                     End else TellError('4');
  222.                     CloseLibrary(pLibrary(WorkbenchBase));
  223.                 End else TellError('3');
  224.                 CloseLibrary(pLibrary(GfxBase));
  225.             End else TellError('2');
  226.             CloseLibrary(pLibrary(GadToolsBase));
  227.         End else TellError('1');
  228.         CloseLibrary(pLibrary(IntuitionBase));
  229.     End;
  230. End;
  231.  
  232. Begin Main End.